package com.wenxixuanwu.fruitstore.mapper;

import com.wenxixuanwu.fruitstore.entity.Product;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ProductMapper {

    @Select("select p.id,p.url,p.name,c.c_name,p.old_price from product p join category c on p.category_id=c.c_id where c.c_id=#{cId}")
    @Result(column = "category_id",property = "categoryId")
    @Result(column = "c_id",property = "cId")
    @Result(column = "old_price",property = "oldPrice")
    List<Product> select(Integer cId);

    /*@Select("select id,name,url from product where category_id=#{categoryId}")
    @Result(column = "category_id",property = "categoryId")
    List<Product> selectByFruitType(Integer categoryId);*/

    @Select("select id,name,detail from product order by sale_count desc limit 0,5")
    List<Product> selectBySaleCount();
}
